[% setvar title New 'tristate' pragma to allow undef to take on NULL semantics %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>New 'tristate' pragma to allow undef to take on NULL semantics</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Nathan Wiger &lt;<a href='mailto:nate@wiger.org'>nate@wiger.org</a>&gt;
  Date: 23 Sep 2000
  Last Modified: 29 Sep 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 275
  Version: 2
  Status: Frozen</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>RFC 263 proposed the introduction of a <code>null</code> keyword for introducting
tristate logic into Perl 6. However, that was abandoned in favor of the
approach specified here, a <code>tristate</code> pragma.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>The <code>tristate</code> pragma allows for undef to take on the RDBMS concept of
<code>NULL</code>, in particular:</p>
<pre>   1. Any operation between a NULL and any other value results
      in NULL

   2. Any comparison between a NULL and any other value is false

   3. No NULL value is equal to any other NULL

   4. A NULL value is neither defined nor undefined</pre>
<p>The <code>tristate</code> pragma is lexically scoped, so that it obeys code
blocks:</p>
<pre>   $a = undef;
   $b = 1;
   $c = $a + $b;    # 1
   {
      use tristate;
      $d = $a + $b; # undef
   }
   $e = $c + $d;    # 1</pre>
<p>In addition, the <code>defined</code> builtin is overloaded as an &quot;is not null&quot;
operator under the pragma:</p>
<pre>   use tristate;
   $name = undef;
   die &quot;Badness&quot; unless defined $name;  # $name is not null</pre>
<p>This simplifies <code>undef</code>, actually: <code>defined($x)</code> will always return
false if <code>$x</code> is <code>undef</code>, regardless of the <code>use tristate</code> pragma.</p>
<p>For more details on theoretical issues, please see the references or RFC
263.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>No idea, too burned out.</p>
<a name='MIGRATION'></a><h1>MIGRATION</h1>
<p>None, unless some fool has a custom <code>tristate</code> module that they
wrote to navigate the tristate area of New York, New Jersey, and
Connecticut. But that should be <code>Tristate</code> anyways.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>RFC 263: Add null() keyword and fundamental data type</p>
<p><a href='http://www.sitelite.nl/mysql/manual_Problems.html' target='_blank'>www.sitelite.nl</a>#IDX666</p>
<p><a href='http://www.unb.ca/web/transpo/mynet/mtx19.htm' target='_blank'>www.unb.ca</a>#r2</p>
</div>
